package com.foo.DAOtest;

import static org.junit.Assert.*;


import org.junit.Test;

import org.movieexample.ws.MovieDAO;
import org.movieexample.ws.ServiceUnavailableException;
import org.movieexample.www.movie.MovieData;
import org.movieexample.www.movie.MovieList;

public class MovieDAOTestCases 
{
	MovieDAO moviedao=new MovieDAO();
	@Test
	public void testGetAllMovieData()  
	{
		try 
		{
			MovieList allData =  moviedao.getAllMovieData();
			assertNotNull(allData);
		} 
		catch (ServiceUnavailableException e) 
		{
			fail("Get All Movie Data testcase failed");
		}
	}
	
	@Test
	public void testGetMovieByName() 
	{
		try 
		{
			MovieData specificMovie =  moviedao.getMovieInfoByName("Love");
			assertEquals("Love", specificMovie.getMovie_name());
		} 
		catch (ServiceUnavailableException e) 
		{
			fail("Get Movie Data By Name testcase failed");
		}
	}
	@Test
	public void testGetMovieByGenre() 
	{
		try 
		{
			MovieList moviegenre =  moviedao.getMovieInfoByGenre("Action");
			assertNotNull(moviegenre);
		} 
		catch (ServiceUnavailableException e) 
		{
			fail("Get Movie Data By Genre testcase failed");
		}
	}
	@Test
	public void testGetMovieByTime() 
	{
		try 
		{
			MovieList movietime =  moviedao.getMovieInfoByTime("4:00pm");
			assertNotNull(movietime);
		} 
		catch (ServiceUnavailableException e) 
		{
			fail("Get Movie Data By Time testcase failed");
		}
	}
	
	@Test
	public void testGetMovieByTheatre() 
	{
		try 
		{
			MovieList movietheatre =  moviedao.getMovieInfoByTheatre("Winchester 23");
			assertNotNull(movietheatre);
		} 
		catch (ServiceUnavailableException e) 
		{
			fail("Get Movie Data By Time testcase failed");
		}
	}
	@Test
	public void testGetMovieByType() 
	{
		try 
		{
			MovieList movietype =  moviedao.getMovieInfoByType("PG");
			assertNotNull(movietype);
		} 
		catch (ServiceUnavailableException e) 
		{
			fail("Get Movie Data By Time testcase failed");
		}
	}
}
